using System;
using System.Collections.Generic;
using System.Linq;

namespace OA.Model
{
    //菜单
    public class Menu: Base
    {
        public virtual int ID { get; set; }

        /// <summary>
        /// 站点编号
        /// </summary>
        public virtual string WebSiteCode { get; set; }

        /// <summary>
        /// 编号
        /// </summary>
        public virtual string Code { get; set; }

        /// <summary>
        /// 上级ID
        /// </summary>
        public virtual string ParentCode { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        public virtual string Name { get; set; }

        /// <summary>
        /// 图标路径
        /// </summary>
        public virtual string IconCls { get; set; }

        /// <summary>
        /// 连接地址
        /// </summary>
        public virtual string Address { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        public virtual int Sort { get; set; }

        /// <summary>
        /// 是否显示
        /// </summary>
        public virtual bool IsShow { get; set; }

        /// <summary>
        /// 站点
        /// </summary>
        public virtual WebSite WebSite { get; set; }

        /// <summary>
        /// 上一级
        /// </summary>
        public virtual Menu Parent { get; set; }

        /// <summary>
        /// 子项
        /// </summary>
        public virtual IList<Menu> Childs { get; set; }

        /// <summary>
        /// 按钮
        /// </summary>
        public virtual IList<Button> Buttons { get; set; }

        /// <summary>
        /// 权限
        /// </summary>
        public virtual IList<Menu> Authoritys { get; set; }


        #region 联合ID判断重写
        public override bool Equals(object obj)
        {
            var ret = false;
            if (obj is Menu)
            {
                Menu pk = obj as Menu;
                ret = (this.WebSiteCode == pk.WebSiteCode && this.Code == pk.Code);
            }
            return ret;

        }

        public override int GetHashCode()
        {
            return (this.WebSiteCode + "_" + this.Code).GetHashCode();
        }
        #endregion

    }
}